package com.fausto.learnimprint.message.consumer

import com.fausto.learnimprint.log.sql.SqlLog
import com.fausto.learnimprint.log.sql.SqlLogDAO
import com.fausto.learnimprint.message.MqConstant
import org.springframework.amqp.rabbit.annotation.RabbitHandler
import org.springframework.amqp.rabbit.annotation.RabbitListener
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
@RabbitListener(queues = [MqConstant.SQL_LOG_QUEUE])
class SqlLogListener {
    @Autowired
    lateinit var sqlLogDAO: SqlLogDAO

    @RabbitHandler
    fun saveLog(log: SqlLog){
        sqlLogDAO.saveSqlLog(log)
    }
}